iT邦幫忙

2021 iThome 鐵人賽

DAY 26
0

如上篇所說,這篇開始需要開始來理解OpenRC的流程。
然而即便這樣,我還是希望用比較just enough的方式來處理,首先看了一下openrc的help string,發現他其實有--verbose的選項可以用,於是我便興沖沖地在Alpine Init的swtich_root前擋了一到busybox sh、讓我先進去/sysroot/etc裡面修改inittab當中openrc的啟動參數。結果它噴了一串kernel OOM訊息:

[   39.361634] init invoked oom-killer: gfp_mask=0x100cca(GFP_HIGHUSER_MOVABLE), order=0, oom_score_adj=0
[   39.362621] CPU: 0 PID: 1 Comm: init Not tainted 5.10.7 #2
[   39.363237] Call Trace:
[   39.363638] [<c040261a>] walk_stackframe+0x0/0xa6
[   39.364069] [<c0abbf50>] show_stack+0x32/0x3e
[   39.364432] [<c0abe718>] dump_stack+0x70/0x8e
[   39.364782] [<c0abd664>] dump_header+0x46/0x23e
[   39.365146] [<c04c5610>] out_of_memory+0x368/0x3b8
[   39.365536] [<c04fc5ee>] __alloc_pages_nodemask+0x4c2/0x8e6
[   39.365963] [<c04ea86a>] handle_mm_fault+0x3fc/0xa66
[   39.366348] [<c0404e2a>] do_page_fault+0xc8/0x256
[   39.366724] [<c040128a>] ret_from_exception+0x0/0xc
[   39.367307] Mem-Info:
[   39.367814] active_anon:384 inactive_anon:23988 isolated_anon:0
[   39.367814]  active_file:0 inactive_file:0 isolated_file:0
[   39.367814]  unevictable:0 dirty:0 writeback:0
[   39.367814]  slab_reclaimable:200 slab_unreclaimable:810
[   39.367814]  mapped:210 shmem:2273 pagetables:27 bounce:0
[   39.367814]  free:259 free_pcp:4 free_cma:0
[   39.370232] Node 0 active_anon:1536kB inactive_anon:95952kB active_file:0kB inactive_file:0kB unevictable:0kB isolated(anon):0kB isolated(file):0kB mapped:840kB dirty:0kB writeback:0kB shmem:9092kB writeback_tmp:0kB kernel_stack:264kB all_unreclaimable? yes
[   39.371978] Normal free:1036kB min:1044kB low:1304kB high:1564kB reserved_highatomic:0KB active_anon:1536kB inactive_anon:95952kB active_file:0kB inactive_file:0kB unevictable:0kB writepending:0kB present:126976kB managed:104528kB mlocked:0kB pagetables:108kB bounce:0kB free_pcp:16kB local_pcp:16kB free_cma:0kB
[   39.374135] lowmem_reserve[]: 0 0
[   39.374584] Normal: 1*4kB (M) 5*8kB (UM) 4*16kB (UM) 1*32kB (M) 2*64kB (UM) 2*128kB (UM) 0*256kB 1*512kB (U) 0*1024kB 0*2048kB 0*4096kB = 1036kB
[   39.375961] 2273 total pagecache pages
[   39.376424] 0 pages in swap cache
[   39.376854] Swap cache stats: add 0, delete 0, find 0/0
[   39.377385] Free swap  = 0kB
[   39.377721] Total swap = 0kB
[   39.378208] 31744 pages RAM
[   39.378536] 0 pages HighMem/MovableOnly
[   39.378935] 5612 pages reserved
[   39.379447] Tasks state (memory values in pages):
[   39.379917] [  pid  ]   uid  tgid total_vm      rss pgtables_bytes swapents oom_score_adj name
[   39.381328] Out of memory and no killable processes...
[   39.382250] Kernel panic - not syncing: System is deadlocked on memory
[   39.383159] CPU: 0 PID: 1 Comm: init Not tainted 5.10.7 #2
[   39.383788] Call Trace:
[   39.384168] [<c040261a>] walk_stackframe+0x0/0xa6
[   39.384751] [<c0abbf50>] show_stack+0x32/0x3e
[   39.385142] [<c0abe718>] dump_stack+0x70/0x8e
[   39.385519] [<c0abc176>] panic+0xfa/0x2a2
[   39.385870] [<c04c563c>] out_of_memory+0x394/0x3b8
[   39.386253] [<c04fc5ee>] __alloc_pages_nodemask+0x4c2/0x8e6
[   39.386686] [<c04ea86a>] handle_mm_fault+0x3fc/0xa66
[   39.387094] [<c0404e2a>] do_page_fault+0xc8/0x256
[   39.387470] [<c040128a>] ret_from_exception+0x0/0xc
[   39.388651] ---[ end Kernel panic - not syncing: System is deadlocked on memory ]---

老實說應該是要進去看怎麼會開個verbose就把busyboxinit給炸了,但是這邊想先繞個路去看一下有沒有其他的verbose可以開。此時發現OpenRC文件有提及:
可以在/etc/rc.conf中,將rc_verbose=yes,便會啟動一定程度的verbose output:

 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/dmesg start
 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/modloop start
 * Mounting modloop  ... [ !! ]
 * ERROR: modloop failed to start
 * Executing: /lib/rc/sh/openrc-run.sh /lib/rc/sh/openrc-run.sh /etc/init.d/sysfs start

如果想要的話,其實也可以去改那隻openrc-run.sh加個set -x來慢慢看。
然而,我倒是被另一件事情吸引了注意力,那就是Alpine Init裡面有一個function

setup_inittab_console(){                                                        
    term=vt100                                                                  
    # Inquire the kernel for list of console= devices                                                                                                          
    consoles="$(for c in console $KOPT_consoles; do list_console_devices $c; done)"
    for tty in $consoles; do                                                    
        # do nothing if inittab already have the tty set up                     
        if ! grep -q "^$tty:" $sysroot/etc/inittab; then                        
            echo "# enable login on alternative console" \                      
                >> $sysroot/etc/inittab                                         
            # Baudrate of 0 keeps settings from kernel                          
            echo "$tty::respawn:/sbin/getty -L 0 $tty $term" \                  
                >> $sysroot/etc/inittab                                         
        fi                                                                      
        if [ -e "$sysroot"/etc/securetty ] && ! grep -q -w "$tty" "$sysroot"/etc/securetty; then
            echo "$tty" >> "$sysroot"/etc/securetty                             
        fi                                                                      
    done                                                                        
} 

我原本以為是OpenRC惹禍的部份,看起來是Alpine Init自作主張去把一票getty設進去造成的。
把這邊抹掉之後,下一篇進板子再試試看~


上一篇
Alpine Linux Porting (1.999) The light at the end of tunnel
下一篇
Alpine Linux Porting (2)
系列文
Port Alpine Linux to open source RISC-V platform30
圖片
  直播研討會
圖片
{{ item.channelVendor }} {{ item.webinarstarted }} |
{{ formatDate(item.duration) }}
直播中

尚未有邦友留言

立即登入留言